package com.hqj.utils;

import com.hqj.enums.ResultEnum;

/**
 * @author 黄啟军
 * @version 1.0
 * @date 2020/7/22 0022
 */
public class ResultUtil {
    /**
     * 请求返回成功
     * @date 2020/4/2 0002 10:48
     * @param data	结果
     * @return com.zl.goods.state.ResultVO<T>
     */
    public static <T> ResultVO<T> success(T data) {
        ResultVO<T> result = new ResultVO<>();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMessage());
        result.setData(data);
        return result;
    }
    public static <T> ResultVO<T> success() {
        return success(null);
    }
    public static <T> ResultVO<T> success(Integer code, String msg) {
        ResultVO<T> result = new ResultVO<>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
    public static <T> ResultVO<T> error() {
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setCode(ResultEnum.FAILED.getCode());
        resultVO.setMsg(ResultEnum.FAILED.getMessage());
        return resultVO;
    }
    public static <T> ResultVO<T> error(Integer code, String msg) {
        ResultVO<T> result = new ResultVO<>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}
